let express = require('express')
let router = express.Router()
router.get('/', async (req, res, next) => {
    // 处理用户信息业务
    let { collection, client, ObjectId } = await req.mgdb.open({ collectionName: 'user' })
    try{
        collection.find({ _id: ObjectId(req.query.decode._id) },).toArray((err, result) => {
            if (err) {
                res.send({ err: 1, msg: '集合操作失败' })
            } else {
                if (result.length > 0) {
                    delete result[0].password
                    res.send({ err: 0, msg: '自动登录成功', data: result[0] })
                } else {
                    res.send({ err: 1, msg: '自动登录失败' })
                }
            }
            client.close()
        })
    }catch(e){
        res.send(e);
    }
})
module.exports = router;